﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CMS_LeaveWordsDetails.aspx.cs" Inherits="Youz.CreditRepay.Manage.CMS.CMS_LeaveWordsDetails" %>


    <style>
        .content {
            padding-bottom: 15px;
            margin-bottom: 15px;
            border-bottom: 1px solid #d1d4d7;
        }

        .date {
            margin-top: 5px;
            color: #9aa1a8;
        }

        .alert {
            margin-top:15px;
        }
         .img-rounded {
            width:60px;
            border-radius: 50em;
            float:left;
        }
        .media-left {
            padding-right:15px;
        }
        .media-right {
            padding-left:15px;
        }
        .media-list.media-list-with-divider > li + li {
            padding-top: 10px;
        }
        .media-list {
            margin-bottom:20px;
        }
        .thumbnail {
            width:64px;
            display:inline-block;
            margin-bottom:5px;
        }
        .media-heading {
            color:#9aa1a8;
        }
    </style>


    <div class="row inbox">
        <div class="col-md-12">

            <div class="panel panel-default">

                <div class="panel-body message">

                    <span class="btn-group">
                        <a class="btn btn-default" href="javascript:;" onclick="loadPage('CMS/CMS_LeaveWordsList.aspx')"><span class="fa fa-mail-reply-all"></span>返回列表</a>
                    </span>

                    <%
                        if (iserror)
                        {
                            %>
                            <div class="alert alert-danger">
                                <strong>留言不存在!</strong>
                            </div>
                            <%
                        }
                        else
                        { 
                    %>
                            <div class="message-title"><%:model.Title %></div>

                            <div class="header">
                                <% 
                                    Youz.CreditRepay.Entity.Member_Info member = new Youz.CreditRepay.BLL.Member_InfoBLL().Get(model.Creator);
                                    string membername = member.LastName + member.FirstName;
                                    if (string.IsNullOrWhiteSpace(member.FirstName) && string.IsNullOrWhiteSpace(member.LastName))
                                        membername = "佚名";
                                %>
								<img src="assets/img/user.png" class="avatar">


								<div class="from">
									<span><%:membername %></span>
									<%:member.MemberAccount %>
								</div>
								<div class="date"><span class="fa fa-paper-clip"></span> <%=model.CreateTime.ToString(Utility.CurrentDataTimeFormat) %></div>

							</div>

                            <div class="content">
                                <p>
                                    <%:model.Content %>
                                </p>
                                <%=string.IsNullOrWhiteSpace(model.Img)?"":"<div><a href='javascript:;' onclick='openImg(\""+model.Img+"\")'><img class='thumbnail' alt='图挂了'  src=\""+model.Img+"\" /></a></div>"%>
                            </div>


                            <ul class="media-list media-list-with-divider">

                                        <% 
                                            foreach (System.Data.DataRow item in dtDetails.Rows)
                                            {
                                                if (Convert.ToBoolean(item["IsAdmin"]))
                                                {
                                                    %>
                                                        <li class="media media-sm">
                                                            <div class="media-body text-right">
                                                                <h4 class="media-heading"><%:item["Creator"] %></h4>
                                                                <p><%:item["Content"] %></p>
                                                                <%=string.IsNullOrWhiteSpace(item["Img"] as string)?"":"<div><a href='javascript:;' onclick='openImg(\""+item["Img"].ToString()+"\")'><img class='thumbnail ' alt='图挂了'  src=\""+item["Img"].ToString()+"\" /></a></div> "%>
                                                                <div class="small"><%=Convert.ToDateTime(item["CreateTime"]).ToString(Youz.CreditRepay.BLL.Core.CurrentDataTimeFormat) %></div>
                                                            </div>
                                                            <a href="javascript:;" class="media-right">
                                                                <img class="media-object img-rounded" alt="" src="/assets/img/admin.png" />
                                                            </a>
                                                        </li>
                                                    <%
                                                }
                                                else
                                                { 
                                                    %>
                                                        <li class="media media-sm">
									                        <a href="javascript:;" class="media-left">
									                            <img class="media-object img-rounded" alt="" src="/assets/img/user.png"/>
									                        </a>
									                        <div class="media-body">
										                        <h4 class="media-heading"><%=membername %></h4>
										                        <p><%:item["Content"] %></p>
                                                                <%=string.IsNullOrWhiteSpace(item["Img"] as string)?"":"<div><a href='javascript:;' onclick='openImg(\""+item["Img"].ToString()+"\")'><img class='thumbnail' alt='图挂了'  src=\""+item["Img"].ToString()+"\" /></a></div> "%>
                                                                <div class="small"><%=Convert.ToDateTime(item["CreateTime"]).ToString(Youz.CreditRepay.BLL.Core.CurrentDataTimeFormat) %></div>
									                        </div>
								                        </li>
                                                    <%
                                                }
                                            }    
                                        %>
                            </ul>
                            <form id="frm" method="post" enctype="multipart/form-data" action="CMS/Handlers/CMS_LeaveWordsHandler.ashx?type=addDetails">
                                <div class="form-group">
                                    <textarea placeholder="内容" rows="5" name="Content" id="Content" class="form-control" maxlength="800"></textarea>
                                </div>
                                <div class="form-group has-feedback">
                                    <input type="file" id="Img" name="Img" onchange="fileChange(this,this.id);" />
                                    <span class="help-block">只能上传.png、.jpg、.jpeg格式的图片,且图片大小不能超过5MB</span>
                                </div>
                                <div class="form-group">
                                    <button class="btn btn-success" type="button" id="btn" onclick="addDetails()">留言</button>
                                </div>
                                <input type="hidden" value="<%=Request.QueryString["leaveWordsID"] %>" name="leaveWordsID" />
                            </form>

                    <%
                        }
                    %>
                </div>

            </div>

        </div>
    </div>
    <!-- Modal -->
	<div class="modal fade" id="modalImg" >
		<div class="modal-dialog">
			<div class="modal-content">
			    <div class="modal-header">
			        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			        <h4 class="modal-title" id="myModalLabel">图片</h4>
			    </div>
			    <div class="modal-body">
                    
                        <img id="img" class="img-responsive" src="" />
                    
			    </div>
			    <div class="modal-footer">
                    <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
			    </div>
			</div>
		</div>
	</div>

    <script src="../assets/js/jquery.form.js"></script>
    <script type="text/javascript">
        //上传文件格式
        var arr2 = ['<%=String.Join("','",CommonHelper.ext)%>'];

        function addDetails() {
            if ($("#Content").val().trim() == "") {
                jalert("内容不能为空");
                return false;
            }
            var $btn = $('#btn').attr('disabled', true);
            $("#frm").ajaxSubmit({
                success: function (responseText, statusText) {
                    var data = eval("(" + responseText + ")");
                    if (data) {
                        if (data.isSuccess) {
                            document.getElementById("frm").reset();
                            window.location.reload();
                        }
                        else {
                            jalert(data.message);
                        }
                    }
                    $btn.removeAttr("disabled");
                }
            });
        }

        function openImg(src) {
            $("#img").attr("src", src);
            $("#modalImg").modal("show");
        }
    </script>

